﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Parentmasterpage.master" CodeBehind="CreateUser.aspx.vb" Inherits="WebApplicationcruises.CreateUser" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .style13
        {
            text-align: left;
        }
        .style14
        {
            width: 152px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table class="style12">
        <tr>
            <td class="style13">
                Create Your Account
            </td>
        </tr>
        <tr>
            <td style="text-align: left">
                <asp:FormView ID="FormView1" runat="server" DataKeyNames="UId" 
                    DataSourceID="SqlDataSource1" DefaultMode="Insert">
                    <EditItemTemplate>
                        UId:
                        <asp:Label ID="UIdLabel1" runat="server" Text='<%# Eval("UId") %>' />
                        <br />
                        Uname:
                        <asp:TextBox ID="UnameTextBox" runat="server" Text='<%# Bind("Uname") %>' />
                        <br />
                        UPassword:
                        <asp:TextBox ID="UPasswordTextBox" runat="server" 
                            Text='<%# Bind("UPassword") %>' />
                        <br />
                        <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                            CommandName="Update" Text="Update" />
                        &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                            CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <br />
                        <table class="style12">
                            <tr>
                                <td class="style14">
                                    User name
                                </td>
                                <td>
                                    <asp:TextBox ID="UnameTextBox" runat="server" Text='<%# Bind("Uname") %>' />
                                </td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td class="style14">
                                    Password</td>
                                <td>
                                    <asp:TextBox ID="UPasswordTextBox" runat="server" 
                                        Text='<%# Bind("UPassword") %>' TextMode="Password" />
                                </td>
                                <td>
                                    <asp:CompareValidator ID="CompareValidator1" runat="server" 
                                        ControlToCompare="UPasswordTextBox" ControlToValidate="UPasswordTextBox0" 
                                        ErrorMessage="Passwrod is not mach" style="color: #FF3300" ValidationGroup="1"></asp:CompareValidator>
                                </td>
                            </tr>
                            <tr>
                                <td class="style14">
                                    Confirm Password</td>
                                <td>
                                    <asp:TextBox ID="UPasswordTextBox0" runat="server" 
                                        Text='<%# Bind("UPassword") %>' TextMode="Password" />
                                </td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td class="style14">
                                    &nbsp;</td>
                                <td>
                                    <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                                        CommandName="Insert" Text="Create User" ValidationGroup="1" />
                                </td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                        </table>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        UId:
                        <asp:Label ID="UIdLabel" runat="server" Text='<%# Eval("UId") %>' />
                        <br />
                        Uname:
                        <asp:Label ID="UnameLabel" runat="server" Text='<%# Bind("Uname") %>' />
                        <br />
                        UPassword:
                        <asp:Label ID="UPasswordLabel" runat="server" Text='<%# Bind("UPassword") %>' />
                        <br />

                    </ItemTemplate>
                </asp:FormView>
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:ConnectionStringDB %>" 
                    DeleteCommand="DELETE FROM [Users] WHERE [UId] = ?" 
                    InsertCommand="INSERT INTO Users(Uname, UPassword) VALUES (?, ?)" 
                    ProviderName="<%$ ConnectionStrings:ConnectionStringDB.ProviderName %>" 
                    SelectCommand="SELECT [UId], [Uname], [UPassword] FROM [Users]" 
                    UpdateCommand="UPDATE [Users] SET [Uname] = ?, [UPassword] = ? WHERE [UId] = ?">
                    <DeleteParameters>
                        <asp:Parameter Name="UId" Type="Int32" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="Uname" Type="String" />
                        <asp:Parameter Name="UPassword" Type="String" />
                    </InsertParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="Uname" Type="String" />
                        <asp:Parameter Name="UPassword" Type="String" />
                        <asp:Parameter Name="UId" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>
            </td>
        </tr>
    </table>
</asp:Content>
